<?php
 /* 处理上传 */
  if ($_POST)
  {
	$unt_zh_name = work_str($_POST["unt_zh_name"]);			//单位类型中文名称
	$unt_en_name = work_str($_POST["unt_en_name"]);			//单位类型英文名称
	$unt_other_name = work_str($_POST["unt_other_name"]);   //单位类型其他语言名称

	$unt_order = work_str($_POST["unt_order"]);				//单位类型顺序
    $unt_id = work_str($_POST['unt_id']);
	
	if($unt_id>'0')
	{
		$query = "UPDATE $TBL_UNTY SET unt_zh_name='$unt_zh_name',unt_en_name='$unt_en_name',unt_other_name='$unt_other_name',unt_order='$unt_order' WHERE unt_id='$unt_id'";
	}
	else
	{
		$query = "INSERT INTO $TBL_UNTY SET unt_zh_name='$unt_zh_name',unt_en_name='$unt_en_name',unt_other_name='$unt_other_name',unt_order='$unt_order'";
	}
	$res = mysql_query($query);
	if (! $res)
	{
	   MyNotice("插入数据库出错,请与管理员联系",2,"unit_type.php");
	   exit(0);
	}
	MyNotice("数据录入成功",2,"unit_type.php");
	exit(0);
  }
  $tpl -> set_file(array("page" => "add_untype.htm"));
  //当为修改时
  if($unt_id=(int)$_GET['id'])
  {
	  $query = "SELECT * FROM $TBL_UNTY WHERE unt_id='$unt_id'";
	  $result = mysql_query( $query) or die(mysql_error());
	  $array = mysql_fetch_array( $result);
	  $tpl->set_var($array);
  }
  $frm_name=($unt_id>'0')?"修改单位类型":"添加单位类型";
  $tpl -> set_var( "frm_name",$frm_name);
  $tpl -> parse("Output","page");
  $tpl -> p("Output");
  exit(0);
?>